package com.firewolf.rabbitmq;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import utils.ConnectionUtils;

public class Sender {
	private static final String EXCHANGE_NAME = "exchange_topic";
	public static void main(String[] args) throws Exception {
		
		
		Connection connection = ConnectionUtils.getMQConnection();
		
		Channel channel = connection.createChannel();
		
		//声明交换机为主题模式的
		channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.TOPIC);
		
		//向路由键为user.add发送消息
		channel.basicPublish(EXCHANGE_NAME, "user.add", null, "添加用户".getBytes());
		
		//向路由键为user.delete发送消息
		channel.basicPublish(EXCHANGE_NAME, "user.delete", null, "删除用户".getBytes());
		
		
	}
}
